package com.yequan.designpattern.proxy.dynamic_proxy.jdk.hello;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @author yequan
 * @date 2021/12/02 16:57
 **/
public class HelloProxy implements InvocationHandler {

    /**
     * 实际被代理对象
     */
    private Object target;

    public HelloProxy(Object target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("调用前: " + method.getDeclaringClass().getName() + "#" + method.getName());
        method.invoke(target, args);
        System.out.println("调用后: " + method.getDeclaringClass().getName() + "#" + method.getName());
        return null;
    }
}
